package patern;

import gui.containerDate.Item;

import java.util.ArrayList;

import javax.security.auth.Subject;

public class Sybject {
	private ArrayList<Opservator> obs;
	protected String s;
	private static Sybject subject = null;

	private Sybject() {
		obs = new ArrayList<Opservator>();
	}

	public static Sybject getInstance(){
    	if(subject == null){
    		subject = new Sybject();
    	}
   		return subject;
    	
    }

	public void Attach(Opservator op) {
		obs.add(op);
	}

	public void Deatach(Opservator op) {
		obs.remove(op);
	}

	public void addNotifyObs(Item item) {
		int i;
		int size;

		size = obs.size();
		for (i = 0; i < size; i++) {
			obs.get(i).add(item);
		}
	}

	public void removeNotifyOps(Item item) {

		for (Opservator opservers : obs) {
			opservers.remove(item);
		}
	}
}